package y24.m4;

import java.math.BigInteger;
import java.util.Scanner;

public class Test7 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int Q = scan.nextInt();
        int[][] ab = new int[m][2];
        for (int i = 0; i < m; i++) {
            ab[i][0] = scan.nextInt();
            ab[i][1] = scan.nextInt();
        }
        int[] sum = new int[Q];
        for (int i = 0; i < Q; i++) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (y == 0) {
                int count = 0;
                for (int j = 0; j < ab.length; j++) {
                    if (ab[j][0] == x || ab[j][1] == x) {
                        sum[i] = 1;
                    }
                }
            } else {
                sum[i] = xy(ab, x, y);
            }
            System.out.println(sum[i]);
        }
    }
    public static int xy(int[][] num,int x,int y){
        int count = 0;
        int size = num.length;
        if (y == 0){
            return count;
        }

        for (int i = 0; i < size; i++) {
            if (num[i][0] == x){
                count += xy(num,num[i][1],y-1) + 1;
            }else if(num[i][1] == x){
                count += 1;
                count += xy(num,num[i][0],y-1) + 1;
            }
        }
        return count;
    }
}
